from sklearn import neural_network
import pickle

from pre_process.read_data import read_train_n_test_data

def train_and_test(dir: str, symbol: str):
    train_x,train_y = read_train_n_test_data(dir, test_size=0)
    predictor = neural_network.MLPClassifier(hidden_layer_sizes=(10,), max_iter=1000, random_state=42)

    print('bp training')
    predictor.fit(train_x, train_y)
    with open('./models/bp_%s.pkl' % symbol, 'wb') as f:
        pickle.dump(predictor, f)
    print('bp saved')
    return



